package com.baosight.sczx.zm.cf.service;

import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.threadlocal.UserSession;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.zm.cf.domain.ZMCFMessageLog;

/**
 * 消息记录
 * <p>Title: ServiceZMCF05.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 严洪浩
 * @version 1.0
 * <pre>Histroy:
 *          2011-7-12 上午05:16:20  严洪浩  Create
 *</pre>
 */
public class ServiceZMCF05 extends ServiceEPBase {

	/**
	 * 初始化方法
	 * <p>Function: initLoad</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCF15</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-7-8上午05:14:44 严洪浩
	 * </p>
	 *
	 */
	@Override
	public EiInfo initLoad(EiInfo inInfo) {
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");//如果不加这个，翻页的统计和显示是错误的
		
		EiInfo outInfo = this.query(inInfo);
		return outInfo;
	}

	/**
	 * 查询方法
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCF15</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-7-8上午05:14:50 严洪浩
	 * </p>
	 *
	 */
	@Override
	public EiInfo query(EiInfo inInfo) {
		if(inInfo.getBlock(EiConstant.queryBlock) == null){
			StaticTools.setQueryParameters(inInfo, "fdEndDate", StaticTools.getDate() + " 23:59:59", true);
		}
		else {
			String endTime = inInfo.getBlock(EiConstant.queryBlock).getCellStr(0, "fdEndDate");
			if(null != endTime && !"".equals(endTime)) {
				if(endTime.length() <= 10) {
					StaticTools.setQueryParameters(inInfo, "fdEndDate", endTime + " 23:59:59", true);
				}
			}
		}
		String fdUserId = UserSession.getUserId() == null ? "" : UserSession.getUserId().toString();//登陆人ID
		StaticTools.setQueryParameters(inInfo, "fdUserId", fdUserId, true);//添加查询条件
		EiInfo outInfo = super.query(inInfo, "ZMCFMessageLog.query", new ZMCFMessageLog());
		return outInfo;
	}
}
